﻿@model PagedList<View_RefundOrder>
@{
    ViewBag.Title = "复审列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    FirstRefundQueryModel paramModel = new FirstRefundQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (FirstRefundQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}
<div style="width:100%;left:0;top:0;height:100%;position:fixed; display:none;" class="bui-ext-mask"></div>

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("towrefundlist", "ordermaster")" method="get">
    <div class="form_query">
        <div>
            销售订单号：
            <input type="text" name="master_order_no" id="master_order_no" class="abc input-default" placeholder="" value="@paramModel.master_order_no">&nbsp;
        </div>
        <div>
            手机号：
            <input type="text" name="account_mobile" id="account_mobile" class="abc input-default" placeholder="" value="@paramModel.account_mobile">&nbsp;
        </div>
        <div>
            会员名称：
            <input type="text" name="member_name" id="member_name" class="abc input-default" placeholder="" value="@paramModel.member_name">&nbsp;
        </div>
        <div>
            代购编号：
            <input type="text" name="replace_buyer_NO" id="replace_buyer_NO" class="abc input-default" placeholder="" value="@paramModel.replace_buyer_NO">&nbsp;
        </div>
        <div>
            退款订单号：
            <input type="text" name="order_no" id="order_no" class="abc input-default" placeholder="" value="@paramModel.order_no">&nbsp;
        </div>
        <div>
            复审状态：
            <select id="two_audit_status" name="two_audit_status">
                <option value="-10" @(paramModel.two_audit_status == -10 ? "selected" : "")>全部状态</option>
                @{
                    dc = new Dictionary<string, string>();
                    var statuslist = YiYiTong.Rocket.Helper.EnumHelper.GetEnumItems(typeof(AuditStatus));
                    foreach (var item in statuslist)
                    {
                        dc.Add(item.Value.ToString(), item.Description);
                    }
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.two_audit_status.ToString());
            </select>&nbsp;
        </div>
        <div>
            申请时间：
            <input type="text" name="beg_time" class="calendar calendar-time" id="beg_time" value="@paramModel.create_time_begin.ToString(1)"> - <input type="text" name="end_time" class="calendar calendar-time" id="end_time" value="@paramModel.create_time_end.ToString(1)">&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>销售订单号</th>
            <th>退款订单号</th>
            <th>购买人</th>
            <th>退款金额</th>
            <th>退款状态</th>
            <th>申请时间</th>
            <th>初审状态</th>
            <th>初审时间</th>
            <th>审核人</th>
            <th>复审状态</th>
            <th>复审时间</th>
            <th>审核人</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.master_order_no</td>
                <td>@m.order_no</td>
                <td>@m.account_mobile @m.member_name @m.replace_buyer_NO</td>
                <td>@m.refund_amt</td>
                <td>
                    @{
                        int order_status = ConvertHelper.ConvertTo<int>(m.status, 0);
                        switch (order_status)
                        {
                            case (int)RefundSatus.Apply:
                                @:<div>@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                                break;
                            case (int)RefundSatus.Succ:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                                break;
                            case (int)RefundSatus.Fail:
                                @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<RefundSatus>(order_status))</div>
                                break;
                        }
                    }
                </td>
                <td>@m.create_time.ToString(1)</td>
                <td>
                    @{
                        int first_audit_status = ConvertHelper.ConvertTo<int>(m.first_audit_status, 0);
                        switch (first_audit_status)
                        {
                            case (int)AuditStatus.Create:
                                @:<div>@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                                break;
                            case (int)AuditStatus.AuditSucc:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                                break;
                            case (int)AuditStatus.AuditFail:
                                @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(first_audit_status))</div>
                                break;
                        }
                    }
                </td>
                <td>@m.first_audit_time</td>
                <td>@m.first_audit_user</td>
                <td>
                    @{
                        int tow_audit_status = ConvertHelper.ConvertTo<int>(m.tow_audit_status, 0);
                        switch (tow_audit_status)
                        {
                            case (int)AuditStatus.Create:
                                @:<div>@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                                break;
                            case (int)AuditStatus.AuditSucc:
                                @:<div class="green">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                                break;
                            case (int)AuditStatus.AuditFail:
                                @:<div class="red">@(MyEnumHelper.GetEnumItemDescription<AuditStatus>(tow_audit_status))</div>
                                break;
                        }
                    }
                </td>
                <td>@m.tow_audit_time.ToString(1)</td>
                <td>@m.tow_audit_user</td>
                <td>
                    <a href="@Url.Action("refundorderinfo", "OrderMaster", new { id = m.order_id})">查看详情</a>
                    @if (m.tow_audit_status == (int)AuditStatus.Create)
                    {
                        @:<a href="javascript:void(0);" onclick="toDo(@m.order_id,'@m.reason','@m.order_no')" class="btnedit">审核</a>
                    }
                </td>
            </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"] | 总退款金额：@ViewData["AllAmt"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>

<script>
    reloadHandler = function () {
        window.location.reload();
    }
    function callBack() {
        window.document.location.reload();
    }

</script>

<style>
    #div_Mask {
        text-align: center;
        line-height: 100px;
        font-weight: bold
    }

    #J_Form {
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,.4);
        position: absolute;
        z-index: 1000;
        top: 0;
        left: 0;
        color: #000;
    }
</style>
<div id="div_Mask" class="hide">
    <form id="J_Form">
        <table class="table table-bordered definewidth m10 " style="width:600px;margin-top:200px;background-color:#fff">
            <tr>
                <th colspan="2">
                    退款订单复审
                </th>
            </tr>
            <tr>
                <td class="tableleft">退款订单号</td>
                <td>
                    <input type="text" readonly="readonly" id="orderno" />
                </td>
            </tr>
            <tr>
                <td class="tableleft">审核结果</td>
                <td>
                    <input type="radio" id="status" name="status" value="1" checked="checked" /> 审核通过
                    <input type="radio" id="status" name="status" value="2" /> 审核拒绝
                </td>
            </tr>
            <tr>
                <td class="tableleft">退款原因</td>
                <td>
                    <textarea id="refundreason" readonly="readonly" class="input-large"></textarea>
                </td>
            </tr>
            <tr id="dvReason" style="display:none;">
                <td class="tableleft">驳回原因</td>
                <td>
                    <textarea id="txtreason" class="input-large"></textarea>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <button type="button" class="btn btn-primary" id="btn_saveexp">审核</button> &nbsp;&nbsp;
                    <button type="button" class="btn btn-success" id="btn_cancel">取消</button>
                </td>
            </tr>
        </table>
    </form>
</div>

<script>
    var seq_id = 0;
    $(document).ready(function() {
       $('input[type=radio][name=status]').change(function() {
           if (this.value == '1') {
               $("#dvReason").hide();
           }
           else if (this.value == '2') {
               $("#dvReason").show();
           }
       });
    });

    function toDo(id,reason,orderno) {
        seq_id = id;
        $("#refundreason").text(reason + "");
        $("#orderno").val(orderno);
        $("#div_Mask").show();
    }
    $("#btn_cancel").click(function () {
        $("#div_Mask").hide();
    });


    $("#btn_cancel").click(function () {
        $("#div_Mask").hide();
    });
    $("#btn_saveexp").click(function () {
        var status = $("input[name='status']:checked").val();
        var msg = $('#txtreason').val();
        if (status == 2) {
            if (msg == "") {
                BUI.Message.Alert("请输入驳回原因", 'warning');
                return false;
            }
        }
        else if(status ==1){
            msg = "";
        }
        else {
            BUI.Message.Alert("审核结果选择错误", 'warning');
            return false;
        }

        url = "@Url.Action("twoaudit", "ordermaster")";
        parameter = {
            order_id: seq_id,
            status: status,
            msg: msg
        };
        $.post(url, parameter, function (result) {
            ShowActionResult(result, reloadHandler);
            $("#div_Mask").hide();
            this.close();
        });
    });
</script>

